import 'dart:convert' show json;

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class UserPrivacy {
  UserPrivacy({
    this.comment,
    this.likes,
  });

  factory UserPrivacy.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : UserPrivacy(
    comment: asT<bool>(jsonRes['comment']),
    likes: asT<bool>(jsonRes['likes']),
  );

  bool comment;
  bool likes;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'comment': comment,
    'likes': likes,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}
